﻿/*-------------------------------------
//
//Copyright (C) 2007 开发二组 版权所有。
//
//文件名：DocumentService.cs
//
//文件功能描述：单据管理的外观
// 
//创建标识：2007.11.16 李鹏
//创建描述：
//
//修改标识: 2007.11.19 曾健铭
//修改描述:修改部分注释.
// 
//修改标识：2007.11.18 殷悦
//修改描述：根据业务逻辑层修改部分方法
//
//修改标识: 2007.11.28 李鹏
//修改描述:增加方法的描述、补充分页读取数据的方法
// 
//------------------------------------*/
using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Data;
using System.Web.Services.Protocols;
using JXMSTC.SmartBusiness.BFL.BLLFactory;
using JXMSTC.SmartBusiness.BFL.IBLL;


/// <summary>
/// 单据管理的外观
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class DocumentService : System.Web.Services.WebService
{

    public DocumentService()
    {

        //如果使用设计的组件，请取消注释以下行 
        //InitializeComponent(); 
    }

    //创建单据对象
    private readonly IDocument bll = BLLAccess.CreateDocument();

    #region //Order

    /// 修改标识：2007.11.22 李鹏
    /// 修改返回类型
    /// <summary>
    /// 插入一条订单
    /// </summary>
    /// <param name="order">订单信息,OrderInfo类型</param>
    /// <returns>返回一个bool类型,true:操作成功;false:操作失败</returns>
    [WebMethod(Description = "插入一条订单")]
    public JXMSTC.SmartBusiness.Common.Model.OrderInfo InsertOrderInfo(JXMSTC.SmartBusiness.Common.Model.OrderInfo order)
    {
        return bll.InsertOrderInfo(order);
    }

    /// 创建标识：2007.11.22  李鹏
    /// <summary>
    /// 增加订单项
    /// </summary>
    /// <param name="strOrderID">订单号</param>
    /// <param name="strProductID">商品编号</param>
    /// <param name="iQuantity">购买数量</param>
    /// <param name="decUnitPrice">单价</param>
    /// <returns>订单项增加成功返回 True,否则返回 False</returns>
    [WebMethod(Description = "增加订单项")]
    public bool AddOrderItem(string strOrderID, string strProductID, int iQuantity, decimal decUnitPrice)
    {
        return bll.AddOrderItem(strOrderID, strProductID, iQuantity, decUnitPrice);
    }

    /// <summary>
    /// 返回订单列表,应用场景:订单管理页面.
    /// </summary>
    /// <param name="strOrderID">订单ID</param>
    /// <returns>返回订单的DataSet</returns>
    [WebMethod(Description = "返回订单列表,应用场景:订单管理页面")]
    public DataSet GetOrderList(string strOrderID)
    {
        return bll.GetOrderList(strOrderID);
    }

    /// <summary>
    /// 返回订单列表,应用场景:订单管理.
    /// </summary>
    /// <param name="iPaymentStatus">是否已付款</param>
    /// <param name="iConsignmentStatus">是否已发货</param>
    /// <param name="iArchivingStatus">是否已归档</param>
    /// <param name="strStartTime">搜索的起始时间</param>
    /// <param name="strEndTime">搜索的结束时间</param>
    /// <returns>返回订单的DataSet</returns>
    [WebMethod(Description = "返回订单列表,应用场景:订单管理")]
    public DataSet GetOrderListByTime(int iPaymentStatus, int iConsignmentStatus, int iArchivingStatus, string strStartTime, string strEndTime)
    {
        return bll.GetOrderList(iPaymentStatus, iConsignmentStatus, iArchivingStatus, strStartTime, strEndTime);
    }

    /// 创建标识：2007.11.28 李鹏
    /// 创建描述：根据性能要求，分页获取订单列表
    /// <summary>
    /// 分页获取订单列表，应用场景：订单管理
    /// </summary>
    /// <param name="PageSize">每页的记录条数</param>
    /// <param name="PageIndex">页码</param>
    /// <param name="strWhere">查询条件</param>
    /// <returns>返回当前页的订单列表</returns>
    [WebMethod(Description = "分页获取订单列表，应用场景：订单管理")]
    public DataSet GetOrderListForPaging(int iPageSize, int iPageIndex, int iPaymentStatus, int iConsignmentStatus, int iArchivingStatus, string strStartTime, string strEndTime)
    {
        return bll.GetOrderListForPaging(iPageSize, iPageIndex, iPaymentStatus, iConsignmentStatus, iArchivingStatus, strStartTime, strEndTime);
    }

    /// 创建标识：2007.11.28 李鹏
    /// 创建描述：计算订单行数
    /// <summary>
    /// 计算订单行数
    /// </summary>
    /// <param name="strWhere">查询条件</param>
    /// <returns>根据查询条件计算订单行数</returns>
    [WebMethod(Description = "计算订单行数")]
    public int GetOrderListRows(int iPaymentStatus, int iConsignmentStatus, int iArchivingStatus, string strStartTime, string strEndTime)
    {
        return bll.GetOrderListRows(iPaymentStatus, iConsignmentStatus, iArchivingStatus, strStartTime, strEndTime);
    }

    /// <summary>
    /// 获取最新订单
    /// </summary>
    /// <returns>返回最新订单列表</returns>
    [WebMethod(Description = "获取最新订单")]
    public DataSet GetLastOrderList(int PageSize, int PageIndex)
    {
        return bll.GetLastOrderList(PageSize, PageIndex);
    }

    /// <summary>
    /// 由订单ID获取该订单的详细信息.应用场景:订单管理和订单打印.
    /// </summary>
    /// <param name="strOrderID">订单ID</param>
    /// <returns>返回订单详细的Model</returns>
    [WebMethod(Description = "由订单ID获取该订单的详细信息.应用场景:订单管理和订单打印.")]
    public JXMSTC.SmartBusiness.Common.Model.V_OrderInfo GetOrderDetail(string strOrderID)
    {
        return bll.GetOrderDetail(strOrderID);
    }

    /// <summary>
    /// 删除订单
    /// </summary>
    /// <param name="strOrderID">订单ID</param>
    /// <returns>返回bool值,删除成功返回True,删除失败返回False</returns>
    [WebMethod(Description = "删除订单")]
    public bool DeleteOrder(string strOrderID,int iSaleManID)
    {
        return bll.DeleteOrder(strOrderID,iSaleManID);
    }

    /// <summary>
    /// 返回一张订单中的商品信息(订单项)列表,应用场景:各个单据页面中的商品信息.
    /// </summary>
    /// <param name="strOrderID">订单ID</param>
    /// <returns>返回订单项的DataSet,填充GridView</returns>
    [WebMethod(Description = "返回一张订单中的商品信息(订单项)列表,应用场景:各个单据页面中的商品信息.")]
    public DataSet GetOrderItem(string strOrderID)
    {
        return bll.GetOrderItem(strOrderID);
    }
   
    /// <summary>
    /// 订单归档,应用场景:订单信息页面中的"订单归档"操作.
    /// </summary>
    /// <param name="strOrderID">订单ID</param>
    /// <param name="iSaleManID">员工编号</param>
    /// <param name="isArchiving">是否已经归档,true表示已经归档,则此方法进行"取消归档"</param>
    /// <returns>返回bool值:归档成功返回True,归档失败返回False</returns>
    [WebMethod(Description="订单归档,应用场景:订单信息页面中的'订单归档'操作.")]
    public bool UpdateArchivingStatus(string strOrderID,int iSaleManID,bool isArchiving)
    {
        return bll.UpdateArchivingStatus(strOrderID, iSaleManID, isArchiving);
    }

    /// 创建标识:2007.11.29 李鹏
    /// 创建描述: 获取一张订单中的商品信息(订单项)列表,用于分页
    /// <summary>
    /// 获取一张订单中的商品信息(订单项)列表,用于分页
    /// </summary>
    /// <param name="PageSize">每页记录数</param>
    /// <param name="PageIndex">当前页</param>
    /// <param name="strOrderID">订单编号</param>
    /// <returns>返回订单项的DataSet</returns>
    [WebMethod(Description = "获取一张订单中的商品信息(订单项)列表,用于分页")]
    public DataSet GetOrderItemForPaging(int iPageSize, int iPageIndex, string strOrderID)
    {
        return bll.GetOrderItemForPaging(iPageSize, iPageIndex, strOrderID);
    }

    /// 创建标识:2007.11.29 李鹏
    /// 创建描述: 获取一张订单中所含订单项的条数
    /// <summary>
    /// 获取一张订单中所含订单项的条数
    /// </summary>
    /// <param name="strOrderID">订单编号</param>
    /// <returns>订单项条数</returns>
    [WebMethod(Description = "获取一张订单中所含订单项的条数")]
    public int GetOrderItemRows(string strOrderID)
    {
        return bll.GetOrderItemRows(strOrderID);
    }

    /// 创建标识:2007.12.04 李鹏
    /// 创建描述:根据订单号判断该订单是否已生成发货单
    /// <summary>
    /// 根据订单号判断该订单是否已生成发货单
    /// </summary>
    /// <param name="strOrderID">订单号</param>
    /// <returns>已生成发货单返回true</returns>
    [WebMethod(Description = "根据订单号判断该订单是否已生成发货单")]
    public bool ExitInvoiceByOrderID(string strOrderID)
    {
        return bll.ExitInvoiceByOrderID(strOrderID);
    }

    #endregion
    
    #region //Invoice
    /// <summary>
    /// 生成发货单,应用场景:订单信息中的"生成发货单"操作.
    /// </summary>
    /// <param name="strOrderID">订单ID</param>
    /// <param name="iSalesmanID">业务员ID</param>
    /// <returns>返回bool值:生成发货单成功返回True,生成发货单失败返回False</returns>
    [WebMethod(Description = "生成发货单,应用场景:订单信息中的'生成发货单'操作.")]
    public bool CreateInvoice(string strOrderID, int iSalesmanID)
    {
        return bll.CreateInvoice(strOrderID, iSalesmanID);
    }

    /// <summary>
    /// 返回发货单列表,应用场景:发货单管理页面.
    /// </summary>
    /// <param name="iConsignmentStatus">是否已发货</param>
    /// <param name="strStartTime">搜索起始时间</param>
    /// <param name="strEndTime">搜索结束时间</param>
    /// <returns>返回发货单的DataSet,填充GridView</returns>
    [WebMethod(Description = "返回发货单列表,应用场景:发货单管理页面.")]
    public DataSet GetInvoiceList(int iConsignmentStatus, string strStartTime, string strEndTime)
    {
        return bll.GetInvoiceList(iConsignmentStatus, strStartTime, strEndTime);
    }

    /// <summary>
    /// 获取分页的发货单列表
    /// </summary>
    /// <param name="iConsignmentStatus">发货单状态</param>
    /// <param name="strStartTime">搜索的起始时间</param>
    /// <param name="strEndTime">搜索的结束时间</param>
    /// <param name="iPageSize">页面大小</param>
    /// <param name="iPageIndex">第几页</param>
    /// <returns>根据查询条件,返回发货单列表</returns>
    [WebMethod(Description = "获取分页的发货单列表,应用场景:发货单管理页面.")]
    public DataSet GetInvoiceListForPaging(int iConsignmentStatus, string strStartTime, string strEndTime, int iPageSize, int iPageIndex)
    {
        return bll.GetInvoiceListForPaging(iConsignmentStatus, strStartTime, strEndTime, iPageSize, iPageIndex); 
    }

    /// <summary>
    /// 由搜索条件获取总的记录数
    /// </summary>
    /// <param name="iConsignmentStatus">发货单状态</param>
    /// <param name="strStartTime">搜索的起始时间</param>
    /// <param name="strEndTime">搜索结束时间</param>
    /// <returns>发货单的记录数</returns>
    [WebMethod(Description = "由搜索条件获取总的记录数")]
    public int GetInvoiceQuantity(int iConsignmentStatus, string strStartTime, string strEndTime)
    {
        return bll.GetInvoiceQuantity(iConsignmentStatus, strStartTime, strEndTime);
    }

    /// <summary>
    /// 由发货单ID获取该发货单的详细信息.应用场景:发货单信息页面和发货单打印页面.
    /// </summary>
    /// <param name="strInvoiceID">发货单ID</param>
    /// <returns>返回发货单详细的Model</returns>
    [WebMethod(Description = "由发货单ID获取该发货单的详细信息.应用场景:发货单信息页面和发货单打印页面.")]
    public JXMSTC.SmartBusiness.Common.Model.V_Invoice GetInvoiceDetail(string strInvoiceID)
    {
        return bll.GetInvoiceDetail(strInvoiceID);
    }

    /// <summary>
    /// 删除发货单,应用场景:发货单管理页面中的"删除"操作.
    /// </summary>
    /// <param name="strInvoiceID">发货单ID</param>
    /// <returns>返回bool值:删除成功返回True,删除失败返回False</returns>
    [WebMethod(Description=" 删除发货单,应用场景:发货单管理页面中的'删除'操作")]
    public bool DeleteInvoice(string strInvoiceID)
    {
        return bll.DeleteInvoice(strInvoiceID);
    }

    /// <summary>
    /// 发货,应用场景:发货单信息页面中的"发货"操作.
    /// </summary>
    /// <param name="strInvoiceId">发货单ID</param>
    /// <param name="iStoreKeeperID">发货人ID</param>
    /// <returns>返回bool值:发货成功返回True,发货失败返回False</returns>
    [WebMethod(Description="发货,应用场景:发货单信息页面中的'发货'操作")]
    public bool UpdateConsignmentStatus(string strInvoiceID, int iStoreKeeperID)
    {
        return bll.UpdateConsignmentStatus(strInvoiceID, iStoreKeeperID);
    }

    #endregion

    #region //Receipt
    /// <summary>
    /// 生成收款单,应用场景:订单信息中的"确认已收款"操作.
    /// </summary>
    /// <param name="strOrderID">订单ID</param>
    /// <param name="iSalesmanID">业务员ID</param>
    /// <returns>返回bool值:生成收款单成功返回True,生成收款单失败返回False</returns>
    [WebMethod(Description = "生成收款单,应用场景:订单信息中的'确认已收款'操作.")]
    public bool CreateReceipt(string strOrderID, int iSalesmanID)
    {
        return bll.CreateReceipt(strOrderID, iSalesmanID);
    }

    /// <summary>
    /// 返回收款单列表,应用场景:收款单管理页面.
    /// </summary>
    /// <param name="strReceiptID">收款单ID</param>
    /// <returns>返回收款单的DataSet</returns>
    [WebMethod(Description = "返回收款单列表,应用场景:收款单管理页面.")]
    public DataSet GetReceiptListByReceiptID(string strReceiptID)
    {
        return bll.GetReceiptList(strReceiptID);
    }

    /// <summary>
    /// 分页获取发货单列表
    /// </summary>
    /// <param name="strStartTime">搜索起始时间,可为空</param>
    /// <param name="strEndTime">搜索结束时间,可为空</param>
    /// <returns>一页发货单数据</returns>
    [WebMethod(Description = "返回收款单列表,应用场景:收款单管理页面.")]
    public DataSet GetReceiptList(string strStartTime, string strEndTime)
    {
        return bll.GetReceiptList(strStartTime, strEndTime);
    }

    /// <summary>
    /// 返回收款单列表,应用场景:收款单管理页面.
    /// </summary>
    /// <param name="strStartTime">搜索起始时间,可为空</param>
    /// <param name="strEndTime">搜索结束时间,可为空</param>
    /// <returns>返回发货单的DataSet</returns>
    [WebMethod(Description = "返回收款单列表,应用场景:收款单管理页面.")]
    public DataSet GetReceiptListForPaging(string strStartTime, string strEndTime, int iPageIndex, int iPageSize)
    {
        return bll.GetReceiptListForPaging(strStartTime, strEndTime,iPageIndex,iPageSize);
    }

    /// <summary>
    /// 由搜索条件获取总的记录数
    /// </summary>
    /// <param name="strStartTime">搜索的起始时间</param>
    /// <param name="strEndTime">搜索的结束时间</param>
    /// <returns>记录数</returns>
    [WebMethod(Description="获取某段时间内生成的收款单记录的数目")]
    public int GetReceiptQuantity(string strStartTime, string strEndTime)
    {
        return bll.GetReceiptQuantity(strStartTime, strEndTime);
    }

    /// <summary>
    /// 由收款单ID获取收款单详细信息,应用场景:收款单打印页面.
    /// </summary>
    /// <param name="strReceiptID"></param>
    /// <returns>返回收款单的Model</returns>
    [WebMethod(Description = "由收款单ID获取收款单详细信息,应用场景:收款单打印页面.")]
    public JXMSTC.SmartBusiness.Common.Model.V_Receipt GetReceiptDetail(string strReceiptID)
    {
        return bll.GetReceiptDetail(strReceiptID);
    }

    /// <summary>
    /// 删除收款单,应用场景:收款单管理页面中的"删除"操作.
    /// </summary>
    /// <param name="strReceiptID">收款单ID</param>
    /// <returns>返回bool值:删除成功返回True,删除失败返回False</returns>
    [WebMethod(Description="删除收款单,应用场景:收款单管理页面中的'删除'操作.")]
    public bool DeleteReceipt(string strReceiptID)
    {
        return bll.DeleteReceipt(strReceiptID);
    }

    #endregion
}

